class Teacher extends User{
    String major = '' //专业
    String education = '' // 学历
    String unit = '' // 所在单位/学校
    String postion = '' // 教师类型,(在校\退休\在职)
    String teacherType = '' //teacherType教学类型（家里、随意等）
    
    static hasMany = [courses:String]// courses可带科目

    String experience = '' // 家教经历
    String salary = '' //薪酬
    static constraints = {
        major(blank: true)
        teacherType(blank: true)
        education(blank: true)
        unit(size: 1..250, blank: true,nullable:true)
        experience(size: 1..500, blank: true,nullable:true)
        salary(size: 1..50, blank: true,nullable:true)
    }
    static mapping = {
       table 'jiajiao_teacher'
       courses cascade:"all-delete-orphan"
    }

    String toString() {
        "${realname}"
    }
            String toStr() {
"""${username}
${ major}
${ education}
${ unit}
${ postion}
${ teacherType}
${ experience}
${ salary}
"""
   }
   static namedQueries = { 
        random { max ->
            if (!max) {
                max = 1
            }
            def now = new Date() 
            lt 'createTime', now - (int)(Math.random()*100+1)
            maxResults(max)
            order("createTime", "asc")
        }
    }
}
